package com.nanmeishu.services.upload.service;

import com.nanmeishu.infrastructure.file.store.utils.QiNiuUtils;
import com.nanmeishu.services.upload.facade.IUploadService;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;

@Service
public class UploadServiceImpl implements IUploadService {
    @Override
    public String upload(MultipartFile file) {
        InputStream inputStream = null;
        String s=null;
        try {
            inputStream = file.getInputStream();
            s = QiNiuUtils.uploadByInputStream(inputStream);
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                inputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        System.out.println("------"+s+"------");
        return s;
    }
}
